Skip to content

Fix the Windows CMake build with clang-cl - #242

Merged
gurchetansingh merged 2 commits into
google:mainfrom
RieBi:windows-clang-cl-build
Nov 18, 2026
Merged

gurchetansingh merged 2 commits into
google:mainfrom
RieBi:windows-clang-cl-build

Conversation

@RieBi

@RieBi RieBi commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #240.

The Windows CMake build of gfxstream_backend fails with clang-cl:

  • common/base/windows/src/time.cpp: Windows.h comes before sys/time.h, which includes
    WinSock2.h. Windows.h includes the older winsock.h, and the two conflict.
  • host/vulkan/vk_common_operations.cpp: a std::string goes to %s in GFXSTREAM_INFO().
    This is undefined behavior. clang-cl rejects it.

Fix

  • time.cpp: include <sys/time.h> before <Windows.h>.
  • vk_common_operations.cpp: pass getReason().c_str().

Test

Clean Windows CMake build, Visual Studio 2026, clang-cl 20, Windows SDK 10.0.26100, default flags,
target gfxstream_backend: completes. Without the time.cpp change, the build stops in
time.cpp. With only the time.cpp change, it stops in vk_common_operations.cpp.

This change was developed with AI assistance (Claude Code; see the Assisted-by trailers).

getReason() returns a std::string. Passing it through the variadic
GFXSTREAM_INFO() is undefined behavior: the log can show incorrect text
or the process can stop. The code is in an _WIN32 block. clang-cl
rejects it (-Wnon-pod-varargs), so the Windows CMake build fails.

Use getReason().c_str().

Test: Windows CMake build with clang-cl (VS 2026, SDK 10.0.26100),
      target gfxstream_backend.

Assisted-by: Claude Code:Claude-Opus-5.5
sys/time.h includes WinSock2.h. When Windows.h comes first, it includes
the older winsock.h, and WinSock2.h then redefines its types. With
Windows SDK 10.0.26100 and clang-cl, the Windows CMake build fails in
time.cpp ("redefinition of 'sockaddr'").

Include sys/time.h first.

Test: clean Windows CMake build with clang-cl (VS 2026, SDK 10.0.26100),
      default flags, target gfxstream_backend.

Assisted-by: Claude Code:Claude-Opus-5.5
@gurchetansingh
gurchetansingh added this pull request to the merge queue Nov 18, 2026
Merged via the queue into google:main with commit 96e34fa Nov 18, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows CMake build with clang-cl fails on main

3 participants